package com.hgzy.meeting.controller;

import com.hgzy.meeting.model.Employee;
import com.hgzy.meeting.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class ApproveAccountController {
    public static final Integer PENDING_APPROVE=0;// 待批准
    @Autowired
    private EmployeeService employeeService;
    @RequestMapping("approveaccount")
    public String approveAccount(Model model){
//        查询出 status 状态等于0的用户 也就是待审批的用户  返回到页面中
        List<Employee> emps=employeeService.getAllEmployees(PENDING_APPROVE);
        model.addAttribute("emps",emps);
        return "approveaccount";
    }

    @RequestMapping("updateStatus")
    public String updateStatus(Integer employeeId,Integer status){
//        查询出 status 状态等于0的用户 也就是待审批的用户  返回到页面中
        int result=employeeService.updateStatus(employeeId,status);
        return "redirect:/admin/approveaccount";
    }
}
